"""Bootstrap for running a Django app under Google App Engine.

The site-specific code is all in other files: settings.py, urls.py,
models.py, views.py.  And in fact, only 'settings' is referenced here
directly -- everything else is controlled from there.

"""

# Standard Python imports.
import os
import sys
import logging
import __builtin__
import webapp2
import views
import forum
from attachment import ImageHandler

# Enable info logging by the app (this is separate from appserver's
# logging).
logging.getLogger().setLevel(logging.INFO)

# Create a Django application for WSGI.
app = webapp2.WSGIApplication( [
    ('/', views.Index ),
    ('/download', views.Download ),
    ('/upload', views.Upload ),
    webapp2.Route(r'/a/i/<file_id:[0-9a-fA-F]{8}>', handler=ImageHandler,
        name='showimage'),
    webapp2.Route(r'/a/i/upload', handler=ImageHandler,
        name='uploadimage'),
    webapp2.Route(r'/f/b/add', handler=forum.views.AddBoard,
        name='addboard'),
    webapp2.Route(r'/f/b/<board_id:[0-9]{1,2}>', handler=forum.views.ListBoard,
        name='listboard'),
    webapp2.Route(r'/f/p/add', handler=forum.views.AddPost,
        name='addpost'),
    webapp2.Route(r'/f/p/update', handler=forum.views.UpdatePost,
        name='updatepost'),
    webapp2.Route(r'/f/p/<post_id:[0-9]+>', handler=forum.views.ListPost,
        name='listpost'),
    ], debug=True )

